import os
import sys


contents = sys.argv[1]
# 返回列表，内装字典
result = []
# 先分类

contents = contents.split('@')

for x in contents:
    # 分类
    os.chdir('./me-text-classification-cnn-rnn-master')
    ret = os.popen('python predict.py ' + x)
    output = ret.read().rstrip()
    ret.close()
    tempdict = {}
    if(output == '宾馆饭店'):
        tempdict["id"] = 1
    elif(output == '城市概况'):
        tempdict["id"] = 2
    elif(output == '地方文化'):
        tempdict["id"] = 3
    elif(output == '购物美食'):
        tempdict["id"] = 4
    elif(output == '交通指引'):
        tempdict["id"] = 5
    elif(output == '旅游服务'):
        tempdict["id"] = 6
    elif(output == '旅游景点'):
        tempdict["id"] = 7
    elif(output == '休闲娱乐'):
        tempdict["id"] = 8
    os.chdir('../')

    # 分析
    os.chdir('./me-sentiment-text-cnn-rnn-master')
    ret = os.popen('python predict.py ' + x)
    output = ret.read().rstrip()
    ret.close()
    if(output == 'positive'):
        tempdict["rank"] = 1
    elif(output == 'negative'):
        tempdict["rank"] = 0
    os.chdir('../')
    result.append(tempdict)

print(result)
